public class ChildGame {
    public static void main(String[] args) {
        //定义一个变量，统计有多个个小孩加入了游戏；

        Child child1 = new Child("小黄");
        child1.join();
        Child child2=new Child("xiaozhang");
        child2.join();

        Child child3=new Child("zhangsan");
        child3.join();
//类变量可以通过类名直接访问
        System.out.println("参与玩耍的小孩个数:"+Child.count);
        System.out.println("child1.count="+child1.count);
        System.out.println("child2.count="+child2.count);
        System.out.println("child3.count="+child3.count);

    }
}

class Child{
    private String name;
    public static int count=0;
    public Child(String name){
        this.name=name;
    }
    public void join(){
        System.out.println(name+"加入了游戏");
        count++;
    }
}
